<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   
   

    <input class="user" type="text">
    <br>
    <input class="pwd" type="text">
    <br>
    <button>登录</button>


    <script src="./tools.js"></script> 

    <script>
         let oUser = document.querySelector('.user');
         let oPwd = document.querySelector('.pwd');
         let oBtn = document.querySelector('button')

         oBtn.onclick = function(){
            let user = oUser.value;
            let pwd = oPwd.value;

            //是否存在user
            let res = getCookie('YYDS_' + user);
            // console.log(res);
            if(res){
                if(res === pwd ){
                    setCookie('LOGIN_USER' ,user);
                    location.href = './03list.html' ;
                }else{
                    alert('密码错误');
                }
            }else{
                alert('用户名不存在') ;
            }
        }
    </script>
</body>
</html>